package com.frkj.yuan.activity;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.frkj.yuan.R;
import com.frkj.yuan.adapter.YuyueOrderServiceDetialsAdapter;
import com.frkj.yuan.base.BaseActivity;
import com.frkj.yuan.fragment.my.YuyueOrderDetialsFragment;
import com.frkj.yuan.fragment.my.YuyueOrderServiceFragment;
import com.frkj.yuan.fragment.my.YuyueOrderXuzhiFragment;
import com.frkj.yuan.utils.FullScreenUtils;

import java.util.ArrayList;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * 作者：菲菲 on 2022/2/21 10:45
 * company：丰蓉信息科技有限公司
 */
public class YuyueOrderServiceDetialsActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, ViewPager.OnPageChangeListener {
    @BindView(R.id.order_view_pager)
    ViewPager mViewPager;
    @BindView(R.id.base_title)
    TextView mTitleMsg;
    @BindView(R.id.rag_order)
    RadioGroup mRadgroup;
    private ArrayList<Fragment> mList = new ArrayList<>();
    @Override
    public int getLayoutId() {
        return R.layout.activity_order_service_detials;
    }
    @OnClick(R.id.base_back)
    public void OnClick(){
        finishWitchAnimation();
    }
    @Override
    public void initLayoutView() {
        FullScreenUtils.getInstance().fullScreen(YuyueOrderServiceDetialsActivity.this,true);

        mTitleMsg.setText("孕妇陪诊");
        initfragment();
        mViewPager.setCurrentItem(0);
        mRadgroup.check(R.id.rad_detials);
        mRadgroup.setOnCheckedChangeListener(this);
        mViewPager.setOnPageChangeListener(this);
        mViewPager.setAdapter(new YuyueOrderServiceDetialsAdapter(getSupportFragmentManager(), mList));
    }
    private void initfragment() {
        YuyueOrderDetialsFragment detialsFragment = new YuyueOrderDetialsFragment();
        mList.add(detialsFragment);
        YuyueOrderServiceFragment serviceFragment = new YuyueOrderServiceFragment();
        mList.add(serviceFragment);
        YuyueOrderXuzhiFragment xuzhiFragment = new YuyueOrderXuzhiFragment();
        mList.add(xuzhiFragment);
    }
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rad_detials:
                mViewPager.setCurrentItem(0, false);
                break;
            case R.id.rad_dianping:
                mViewPager.setCurrentItem(1, false);
                break;
            case R.id.rad_yuyue:
                mViewPager.setCurrentItem(2, false);
                break;
        }
    }
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }
    @Override
    public void onPageSelected(int position) {
        switch (position) {
            case 0:
                mRadgroup.check(R.id.rad_detials);
                break;
            case 1:
                mRadgroup.check(R.id.rad_dianping);
                break;
            case 2:
                mRadgroup.check(R.id.rad_yuyue);
                break;
        }
    }
    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
